package com.example.moduletwo.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.example.baselibrary.util.LKToastUtil;
import com.example.moduletwo.R;
import com.example.moduletwo.adapter.binder.TestAdapterBinder;
import com.example.mvp.adapter.BaseLibAdapter;
import com.example.moduletwo.adapter.delegate.TestAdapterDelegate;
import com.example.mvp.binder.BaseDataBinder;
//import com.example.mvp.binder.BaseAdapterDataBinder;

import java.util.List;

/**
 * 测试适配器操作处理类
 * Created by sun.li on 2018/6/6.
 *
 * @author sun.li
 */

public class TestAdapter extends BaseLibAdapter<TestAdapterDelegate,String>{

    public TestAdapter(Context context, List<String> mList) {
        super(context, mList);
    }

    @Override
    protected void bindEvenListener(TestAdapterDelegate viewDelegate,  int position) {
        atiTextOnClickListener(viewDelegate,position);
    }

    private void atiTextOnClickListener(final TestAdapterDelegate viewDelegate, final int position) {
        viewDelegate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(null!=getData()){
                    String str = getData().get(position);
                    LKToastUtil.showToastShort(str);
//                    viewDelegate.setText(str+"_"+v.getId());
                    getData().set(position,str+"_"+v.getId());
                    notifyDataSetChanged();
                }

            }
        }, R.id.tv_ati_text);
    }

    @Override
    protected void notifyView(TestAdapterDelegate viewDelegate,  int position) {
//        viewDelegate.setText(getData().get(position));
    }

    @Override
    public Class getDelegateClass() {
        return TestAdapterDelegate.class;
    }

    @Override
    public BaseDataBinder getDataBinder() {
        return new TestAdapterBinder();
//        return null;
    }
}
